package com.smartboot.plus.page;

import java.util.List;

public class IPage<T> {
    private int current;  // 当前页码，从1开始
    private int size;     // 每页显示多少条
    private long total;   // 总记录数
    private List<T> records; // 当前页的记录

    public IPage() {
        super();
    }

    // 构造方法
    public IPage(int current, int size, long total) {
        this.current = current - 1; // 转换成从0开始的页码
        this.size = size;
        this.total = total;
    }

    public IPage(int current, int size) {
        this.current = current - 1; // 转换成从0开始的页码
        this.size = size;
    }

    // 获取起始位置
    public int getStart() {
        return current * size; // 从0开始计算
    }

    // Getters and setters
    public int getCurrent() {
        return current + 1; // 返回给前端时转换回1开始的页码
    }

    public void setCurrent(int current) {
        this.current = current - 1; // 转换成从0开始的页码
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }
}
